﻿@model Lokad.Cloud.Console.WebRole.Models.Overview.DeploymentModel
@{ ViewBag.Title = "Lokad.Cloud Administration Console - Overview"; }

<h1>Lokad.Cloud Hosted Service Overview</h1>
<p>Details for the @Model.HostedService.ServiceLabel Hosted Service.</p>

<table class="table">
<tr>
	<th style="text-align: right;">Name (Subdomain):</th>
	<td><b>@Model.HostedService.ServiceName</b></td>
</tr>
<tr>
	<th style="text-align: right;">Label:</th>
	<td><b>@Model.HostedService.ServiceLabel</b></td>
</tr>
@if (!String.IsNullOrEmpty(Model.HostedService.Description)) {
	<tr>
		<th style="text-align: right;">Description:</th>
		<td><em>@Model.HostedService.Description</em></td>
	</tr>
}
<tr>
	<th style="text-align: right;">Storage Account:</th>
	<td><code>@Model.HostedService.StorageAccountName</code>, with key <code>@Model.HostedService.StorageAccountKeyPrefix...</code></td>
</tr>
</table>

<h2>Azure Deployments</h2>
<p>The following deployments have been discovered in the @Model.HostedService.ServiceLabel Hosted Service.</p>

<table class="table">
@foreach (var deployment in Model.HostedService.Deployments) {
	<tr>
		<td>
			@Html.OkCancelIcon(deployment.IsRunning) <b>@deployment.Slot</b><br />
			<br />
			@if(deployment.IsTransitioning) { <b>UPDATING</b> }
			else if(!deployment.IsRunning) { <b>SUSPENDED</b> }
		</td>
		<td>
			@deployment.DeploymentLabel<br />
			<br />
			<b>@deployment.InstanceCount Worker Instances</b><br/><br />
			@if (deployment.IsRunning) {
				using (Html.BeginForm("InstanceCount", "Overview")) {
					@Html.Hidden("slot", deployment.Slot)
					<div class="warning">Update to @Html.TextBox("instanceCount", deployment.InstanceCount, new { style = "width:25px;" }) Worker Instances: <input type="submit" value="Request" /></div>
				}
			}
			else if(deployment.IsTransitioning) { <div class="warning">An Azure deployment update is currently in progress.</div> }
			else if(!deployment.IsRunning) { <div class="warning">The Azure deployment is suspended.</div> }
		</td>
	</tr>
}
</table>
